﻿begin
as_pdf3.init;
as_pdf3.set_font( as_pdf3.load_ttf_font( 'MY_DIR', 'simfang.ttf', 'CID', p_compress => false ), 15 );
as_pdf3.write('默认左对齐第一行');
as_pdf3.set_font( as_pdf3.load_ttf_font( 'MY_DIR', 'simfang.ttf', 'CID', p_compress => false ), 12 );
as_pdf3.write('默认左对齐第二行'
, p_x => -1 --1 强制回车
, p_y => -1 --1 强制换行
);
as_pdf3.write( '1234567页面右对齐'
, p_x => -1 --1 强制回车
, p_y => -1 --1 强制换行
--p_width未使用，因此aligments使用页面宽度
, p_alignment => 'right'
);
as_pdf3.write( '1页面右对齐'
, p_x => -1 --1 强制回车
, p_y => -1 --1 强制换行
--p_width未使用，因此aligments使用页面宽度
, p_alignment => 'right'
);
as_pdf3.write( '1234567宽度300内右对齐'
, p_x => -1 --1 强制回车
, p_y => -1 --1 强制换行
, p_width => 300
, p_alignment => 'right'
);
as_pdf3.write( '1宽度300内右对齐'
, p_x => -1 --1 强制回车
, p_y => -1 --1 强制换行
, p_width => 300
, p_alignment => 'right'
);
as_pdf3.save_pdf;
end;


--------------------------------------------------------------------

declare
x pls_integer;
begin
as_pdf3.init;
as_pdf3.write( 'But others fonts and encodings are possible using TrueType fontfiles.' );
x := as_pdf3.load_ttf_font( 'MY_DIR', 'refsan.ttf', 'CID', p_compress =>false );
as_pdf3.set_font( x, 12 );
as_pdf3.write( 'The Windows MSReference SansSerif font contains a lot of encodings, for instance', -1, 700 );
as_pdf3.set_font( x, 15 );
as_pdf3.write( 'Albanian: Kush mund të lexoni këtë diçka si kjo', -1, -1 );
as_pdf3.write( 'Croatic: Tko može čitati to nešto poput ovoga', -1, -1 );
as_pdf3.write( 'Russian: Кто может прочитать это что-то вроде этого', -1, -1);
as_pdf3.write( 'Greek: Ποιος μπορεί να διαβάσει αυτό το κάτι σαν αυτό', -1, -1 );
--
as_pdf3.set_font( 'helvetica', 12 );
as_pdf3.write( 'Or by using a TrueType collection file (ttc).', -1, 600 );
as_pdf3.load_ttc_fonts( 'MY_FONTS', 'cambria.ttc', p_embed => true, p_compress => false );
as_pdf3.set_font( 'cambria', 15 ); -- font family
as_pdf3.write( 'Anton, testing 1,2,3 with Cambria', -1, -1 );
as_pdf3.set_font( 'CambriaMath', 15 ); -- fontname
as_pdf3.write( 'Anton, testing 1,2,3 with CambriaMath', -1, -1 );
--
as_pdf3.set_font( 'helvetica', 12 );
as_pdf3.write( 'Or if you need to generate a PDF report in Chinese:', -1, 520 );
as_pdf3.set_font( as_pdf3.load_ttf_font( 'MY_DIR', 'simfang.ttf', 'CID', p_compress => false ), 12 );
as_pdf3.write( 'Chinese: 在中国的一个简单的句子', -1, -1 );
--
as_pdf3.save_pdf;
end;

---------------------------------------------------------------------------------------
begin
as_pdf3.init;
as_pdf3.write('Page 1.');
as_pdf3.new_page;
as_pdf3.write('Page 2.');
as_pdf3.save_pdf;
end;

--------------------------------------------------------------------------------------------
declare
t_query varchar2(1000);
t_rc sys_refcursor;
begin
as_pdf3.init;
t_query := 'select 1, 2, 3, 4, 5 from dual';
--as_pdf3.query2table( t_query );
open t_rc for t_query;
as_pdf3.refcursor2table( t_rc, as_pdf3.tp_col_widths( 100, 40, 50, 120, 110 ) );
as_pdf3.save_pdf;
end;
--------------------------------------------------------------------------------------------
select rownum c1, rownum * 2 c2, rownum c3 from dual connect by level <= 3


begin
as_pdf3.init();
as_pdf3.query2table
('select rownum c1, rownum * 2 c2, rownum c3 from dual connect by level <= 3', p_headers => as_pdf3.tp_headers('Try', 'Something', 'like this'));
as_pdf3.save_pdf;
end;
---------------------------------------------------------------------------------------------

begin
as_pdf3.init;
as_pdf3.write('Minimal usage');
as_pdf3.write('Minimal usage', -1, -1 );
as_pdf3.write('Minimal usage', -1, -1 );
as_pdf3.save_pdf;
end;

or

begin
as_pdf3.init;
as_pdf3.write('Minimal usage' || chr(10) );
as_pdf3.write('Minimal usage' || chr(10) );
as_pdf3.write('Minimal usage' || chr(10) );
as_pdf3.save_pdf;
end;

---------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------
declare
v_test varchar2(20) := 'header info';
begin
as_pdf3.init();
as_pdf3.set_page_proc( q'~
begin
as_pdf3.set_font( 'helvetica', 8 );
as_pdf3.put_txt( 10, 15, 'Page #PAGE_NR# of "PAGE_COUNT#' );
as_pdf3.set_font( 'helvetica', 12 );
as_pdf3.put_txt( 350, 15, 'footer info');
end;~' );
as_pdf3.save_pdf ('MY_DIR','my.pdf');
end;
---------------------------------------------------------------------------------------------
---'----------------------

declare v_test varchar2(20);
bbb blob;
begin
v_test:='DDDDDDDDDDDDDDDDDDD';
as_pdf3.init();
as_pdf3.set_page_proc(q'~
begin
as_pdf3.set_font('helvetica', 8 );
as_pdf3.put_txt(10, 15, 'Page #PAGE_NR# of "PAGE_COUNT#');
as_pdf3.set_font('helvetica', 12 );
as_pdf3.put_txt(350, 15, 'This is a footer text');
as_pdf3.set_font('helvetica', 'B', 15 );
as_pdf3.put_txt(200, 780, 'This is a header text');
end;~' );
as_pdf3.put_txt( 200, 750, v_test);
as_pdf3.new_page;
as_pdf3.write('Page 2.');
as_pdf3.save_pdf ('MY_DIR','my.pdf');
end;


